package com.spzx.product.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spzx.product.domain.Category;
import com.spzx.product.domain.ProductSpec;
import com.spzx.product.service.CategoryBrandService;
import com.spzx.product.service.CategoryService;
import com.spzx.product.service.ProductSpecService;
import com.spzx.product.mapper.ProductSpecMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author 老韦
* @description 针对表【product_spec(商品规格)】的数据库操作Service实现
* @createDate 2024-09-24 14:07:17
*/
@Service
public class ProductSpecServiceImpl extends ServiceImpl<ProductSpecMapper, ProductSpec>
    implements ProductSpecService{

    @Resource
    CategoryService categoryService;

    @Resource
    CategoryBrandService categoryBrandService;
    @Override
    public Page<ProductSpec> listProductSpec(Page<ProductSpec> page, ProductSpec productSpec) {


        return baseMapper.selectSpecList(page,productSpec);
    }

    @Override
    public ProductSpec getInfo(Long id) {
        ProductSpec productSpec = baseMapper.selectById(id);
        List<Category> categories = categoryService.treeSelect(productSpec.getCategoryId());

        productSpec.setCategoryIdList(categoryBrandService.select3CategoryId(productSpec.getCategoryId()));
        return productSpec;
    }
}




